<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title></title>
    </head>
    <body>
        <form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>">
        <input type="text" name="input1" />1st number
        <select name="operation">
            <option>+</option><option>-</option><option>X</option><option>/</option>
        </select>
        <input type="text" name="input2" />2nd number
        <input type="submit" name="submit" value="SUBMIT">
        </form>
        <?php
        $submit = $_GET['submit'];
        $first  = $_GET['input1'];
        $second = $_GET['input2'];
        $action = $_GET['operation'];
        if($first!="" || $second!="")
            {
            if($action=="+")
                {
                $ans = $first + $second;
                echo "Sum = $ans";
                }
            else if($action=="-")
                {
                $ans = $first - $second;
                echo "Difference = $ans";
                }
            else if($action=="X")
                {
                $ans = $first * $second;
                echo "Product = $ans";
                }
            else
                {
                $ans = $first / $second;
                echo "Dividend = $ans";
                }
            }

            else
                {
                echo "</br>provide 1st & 2nd numbers both and press SUBMIT button";
                }
            
        
        ?>
    </body>
</html>
